import 'package:flutter/material.dart';

class AnimationDemoPage extends StatefulWidget {
  @override
  State createState() {
    return _AnimationDemoPageState();
  }
}

class _AnimationDemoPageState extends State<AnimationDemoPage> {
  bool isSelect = false;

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("animation 组件使用")),
      body: Container(
        width: double.infinity,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            AnimatedOpacity(
              opacity: isSelect ? 0 : 1,
              duration: Duration(seconds: 1),
              child: AnimatedContainer(
                duration: Duration(seconds: 1),
                width: isSelect ? 0 : 200,
                color: Colors.blue,
                child: const Text("你好呀,我市制定恢复", softWrap: false),
              ),
            ),
            AnimatedCrossFade(
              firstChild: Text("第一个text"),
              secondChild: Text("第二个text"),
              crossFadeState:
                  isSelect
                      ? CrossFadeState.showSecond
                      : CrossFadeState.showFirst,
              duration: Duration(seconds: 1),
            ),
            AnimatedScale(
              scale: isSelect ? 1 : 2,
              duration: Duration(seconds: 1),
              child: Text("Scale效果"),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {
          setState(() {
            isSelect = !isSelect;
          });
        },
      ),
    );
  }
}
